package com.starblink.brand.adapter

import com.starblink.android.basic.adapter.BaseBindingVH
import com.starblink.android.basic.ext.commContext
import com.starblink.brand.bean.BrandAllTitleBean
import com.starblink.brand.databinding.CellBrandLetterBinding
import com.starblink.brand.R
import com.starblink.brand.ui.AllLetterI

class BrandLetterCell (binding: CellBrandLetterBinding, private val allLetterI:AllLetterI) :
    BaseBindingVH<BrandAllTitleBean, CellBrandLetterBinding>(binding) {

    override fun onBind(model: BrandAllTitleBean, position: Int) {
        binding.tvLetterTitle.text=model.key.toString()
        if(model.ifChecked){
            //选中状态
            binding.tvLetterTitle.setBackgroundResource(R.drawable.bg_rect_blue_corner)
            binding.tvLetterTitle.setTextColor(commContext().resources.getColor(com.starblink.basic.style.R.color.gu_white))
        }else if(model.ifEnable){
            //可选状态
            binding.tvLetterTitle.setBackgroundResource(com.starblink.basic.style.R.color.transparent)
            binding.tvLetterTitle.setTextColor(commContext().resources.getColor(com.starblink.basic.style.R.color.gu_neutral_600))
        }else{
            binding.tvLetterTitle.setBackgroundResource(com.starblink.basic.style.R.color.transparent)
            binding.tvLetterTitle.setTextColor(commContext().resources.getColor(com.starblink.basic.style.R.color.gu_neutral_400))
        }

        binding.tvLetterTitle.setOnClickListener {
            allLetterI.scrollToLetter(model.key)
        }
    }
}